/*
 * BoxSelector.h
 *
 *  Created on: Oct 14, 2013
 *      Author: filipe
 */

#ifndef BOXSELECTOR_H_
#define BOXSELECTOR_H_

	#include <string>
	#include<opencv/cv.h>
	#include<opencv/highgui.h>

	#define MYMIN(x,y) (x < y)?(x):(y)

	class BoxSelector
	{
		protected:
			cv::Mat _reference_image;
			cv::Mat _viewer_image;
			cv::Rect _box;
			bool _mouse_pressed;
			bool _box_selected;

			virtual void _DefaultConstructor();

		public:
			BoxSelector();
			BoxSelector(cv::Mat &img);
			BoxSelector(std::string filename);
			virtual ~BoxSelector();

			void SetImage(cv::Mat &img);
			void SetBox(cv::Rect box);

			cv::Rect GetBox(void) const;
			virtual void Loop(void); // loop until user press 'q'

			bool BoxSelected() const;

			// it has to be public to be used as mouse event handler
			void MouseEventHandler(int event, int x, int y, int flags, void* param);
	};

#endif
